s = input().replace(' ','')
for d in s:
    if d !='(' and d != ')' and d != '{' and d != '}'and d !='<' and d != '>'and d !='[' and d != ']':
        s=s.replace(d,'')
while'{}' in s or '()' in s or '[]' in s or '<>' in s:
    s = s.replace('{}','')
    s = s.replace('()', '')
    s = s.replace('[]', '')
    s = s.replace('<>', '')
if len(s) > 0:
    print('False')
else:
    print('True')

